Imports System
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.Text

Imports DevExpress.ExpressApp
Imports DevExpress.ExpressApp.Actions
Imports DevExpress.Persistent.Base
Imports DevExpress.Data.Filtering

Public Class FindBySubjectController
    Inherits DevExpress.ExpressApp.ViewController

    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()
        RegisterActions(components)

    End Sub

    Private Sub FindBySubjectAction_Execute(ByVal sender As System.Object, ByVal e As DevExpress.ExpressApp.Actions.ParametrizedActionExecuteEventArgs) Handles FindBySubjectAction.Execute

        Dim objectSpace As IObjectSpace = Application.CreateObjectSpace()
        Dim paramValue As String = TryCast(e.ParameterCurrentValue, String)
        If (Not String.IsNullOrEmpty(paramValue)) Then
            paramValue = "%" & paramValue & "%"
        End If
        Dim obj As Object = objectSpace.FindObject(CType(View, ListView).ObjectTypeInfo.Type, _
            New BinaryOperator("Subject", paramValue, BinaryOperatorType.Like))
        If Not obj Is Nothing Then
            e.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpace, obj)
        End If

    End Sub
End Class
